<?php
/**
 * FilesController.php
 *
 * @copyright   2023 thingsworld.com.cn - All Rights Reserved
 * @link        http://thingsworld.com.cn/
 * @author      stiffer.chen <chenl@thingsworld.com.cn>
 * @created     2023-02-16 04:07:33
 * @modified    2023-02-16 04:07:33
 *
 */

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Repositories\FileRepo;

class FilesController extends BaseController
{
    /**
     * @OA\Post(
     *     path="/files/filesStore",
     *     operationId="files_post",
     *     tags={"FilesUpload"},
     *     summary="文件上传（仅用于H5扫码）",
     *     description="文件上传（仅用于H5扫码）",
     *     @OA\RequestBody(
     *         description="表单数据",
     *         @OA\MediaType(
     *             mediaType="multipart/form-data",
     *             @OA\Schema(
     *                 type="object",
     *                 required={"attachment"},
     *                 @OA\Property(property="attachment", description="上传文件, 支持文件类型: json、png、gif、jpg、bmp、xls、xlsx、ppt、pptx、doc、docx、txt", type="file")
     *             )
     *         )
     *     ),
     *     @OA\Response(response=200, description="请求成功"),
     *     @OA\Response(response=401, description="鉴权失败"),
     *     @OA\Response(response=422, description="请求异常")
     * )
     */
    public function store(Request $request)
    {
        try {
            $data = FileRepo::upload();
            return message('上传成功', true, $data);
        } catch (\Exception $e) {
            return message($e->getMessage(), false);
        }
    }
}